Skip to content

Add URI template support to ProxyExchange for observability#4137

Merged
ryanjbaxter merged 1 commit intospring-cloud:4.3.xfrom
fru1tworld:fix-3458-proxyexchange-uri-template
Apr 9, 2026
Merged

Add URI template support to ProxyExchange for observability#4137
ryanjbaxter merged 1 commit intospring-cloud:4.3.xfrom
fru1tworld:fix-3458-proxyexchange-uri-template

Conversation

@fru1tworld
Copy link
Copy Markdown
Contributor

ProxyExchange.exchange() used rest.exchange(RequestEntity, ...) which loses
the URI template pattern, causing Micrometer http.client.requests uri tag
to always be "none".

Add uri(String, Map) overload that preserves the template so RestTemplate
can pass it to Micrometer.

Fixes #3458

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR fixes missing URI template observability for MVC ProxyExchange backend calls by preserving the URI template pattern through to RestTemplate, enabling Micrometer’s http.client.requests uri tag to be populated (instead of "none").

Changes:

  • Add a ProxyExchange.uri(String uriTemplate, Map<String, ?> uriVariables) overload that stores the template + variables and expands to a concrete URI.
  • Update ProxyExchange.exchange(...) to call RestTemplate.exchange(String, ...) when a template is available, preserving the URI template for observability.
  • Add an integration test asserting that the http.client.requests metric contains uri="/foos/{id}" when using the new overload.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
spring-cloud-gateway-proxyexchange-webmvc/src/main/java/org/springframework/cloud/gateway/mvc/ProxyExchange.java Introduces URI-template-aware uri(...) overload and routes exchanges through RestTemplate.exchange(String, ...) to preserve template metadata for Micrometer.
spring-cloud-gateway-proxyexchange-webmvc/src/test/java/org/springframework/cloud/gateway/mvc/ProductionConfigurationTests.java Adds coverage validating that URI template usage results in a templated uri tag in http.client.requests.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

@ryanjbaxter
Copy link
Copy Markdown
Contributor

Please sign your commit and also submit this against the 4.3.x branch

Signed-off-by: fru1tworld <fruitworld.planet@gmail.com>
@fru1tworld fru1tworld force-pushed the fix-3458-proxyexchange-uri-template branch from 8e754d0 to 6117ec4 Compare April 8, 2026 23:45
@fru1tworld fru1tworld changed the base branch from main to 4.3.x April 8, 2026 23:45
@fru1tworld
Copy link
Copy Markdown
Contributor Author

Rebased onto 4.3.x and signed the commit. Thanks for the feedback!

@ryanjbaxter ryanjbaxter merged commit 24abe33 into spring-cloud:4.3.x Apr 9, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

MVC ProxyExchange does not provide observability of URI template

4 participants